import { actionTypes } from '../actions/userAction';

const userReducer = function (state = null, action = {}) {
  switch (action.type) {
  case actionTypes.getUserData:
    return state;
  case actionTypes.setUserData:
    if (!action.payload) return null;

    return {
      ...state,
      ...action.payload,
    };

  default:
    return state;
  }
}

export default userReducer;
